<?php

namespace api\common;


class Api
{
    public function success($data, $code = 200, $msg = '')
    {
        return $this->result($data, $code, $msg);
    }

    public function error($msg = '', $code = 400, $data = [])
    {
        return $this->result($data, $code, $msg);
    }

    public function result($data, $code = 0, $msg = '')
    {
        $result = [
            'code' => $code,
            'msg' => $msg,
            'time' => $_SERVER['REQUEST_TIME'],
            'data' => $data,
        ];
        return $result;
    }
}